import 'package:flutter/material.dart';
import 'package:flutter_scaffold/flutter_scaffold.dart';

class GestureDemoPage extends StatefulWidget {
  @override
  State createState() {
    return _GestureDemoPageState();
  }
}

class _GestureDemoPageState extends State<GestureDemoPage> {
  double _scale = 1.0;
  double _preScale = 1.0;

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("gesture 使用")),
      body: GestureDetector(
        onScaleUpdate: (details) {
          Log.i("===>${_scale}");
          setState(() {
            _scale = _preScale*details.scale;
          });
        },
        onScaleStart: (de){
          _preScale = _scale;
        },
        onScaleEnd: (de){
          Log.i("===>end");
        },
        child: SizedBox(
          width: double.infinity,
          height: double.infinity,
          child: Text(
            "手势缩放功能",
            textScaler: TextScaler.linear(_scale),
            style: TextStyle(color: Colors.red, backgroundColor: Colors.blue),
          ),
        ),
      ),
    );
  }
}
